from django.contrib import admin
from django.contrib.contenttypes import generic     
from apps.food.models import Category, CategoryMembership, Dish, UserProfile, Review, Place, Chain, Restaurant, Photo, ProfilePhoto

class PhotoAdmin(admin.ModelAdmin):
    list_display = ('content_object', 'content_type', 'admin_image')
    exclude = ('object_id',)

class ProfilePhotoInline(generic.GenericTabularInline):
    model = ProfilePhoto
    extra = 0

class ProfileAdmin(admin.ModelAdmin):
    inlines = [ 
        ProfilePhotoInline,               
    ]
    
class PhotoInline(generic.GenericTabularInline):
    model = Photo
    extra = 1

class DishAdmin(admin.ModelAdmin):
    inlines = [
        PhotoInline,
    ]

class RestaurantAdmin(admin.ModelAdmin):
    exclude = ('derivedTypeName',)

class RestaurantInline(admin.TabularInline):
    model = Restaurant
    fk_name = 'chain'
    extra = 1
    
class ChainAdmin(admin.ModelAdmin):
    inlines = [ RestaurantInline, ]
    exclude = ('derivedTypeName',)
    
admin.site.register(Category)
admin.site.register(CategoryMembership)
admin.site.register(Dish, DishAdmin)
admin.site.register(UserProfile, ProfileAdmin)
admin.site.register(Review)   
admin.site.register(Place)
admin.site.register(Restaurant, RestaurantAdmin)
admin.site.register(Chain, ChainAdmin)
admin.site.register(Photo, PhotoAdmin)
admin.site.register(ProfilePhoto)